package numberSix;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class NumberSix {

    @MyTest
    public void method1(){
        System.out.println("method1");
    }

    public void method2(){
        System.out.println("method2");
    }
    @MyTest
    public void method3(){
        System.out.println("method3");
    }

    public void method4(){
        System.out.println("method4");
    }
    public static void main(String[] args) throws InvocationTargetException, IllegalAccessException {
        NumberSix numberSix=new NumberSix();
        Class<? extends NumberSix> aClass = numberSix.getClass();
        Method[] declaredMethods = aClass.getDeclaredMethods();
        for (Method declaredMethod : declaredMethods) {
            if (declaredMethod.isAnnotationPresent(MyTest.class)){
                declaredMethod.invoke(numberSix);
            }
        }
    }
}
